package com.tfswx.ruleengine.compute.gzjy.felfunc;

import com.alibaba.fastjson.JSON;
import com.greenpineyu.fel.context.FelContext;
import com.tfswx.ruleengine.compute.gzjy.BaseFn;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Ricky
 * @date 2021/4/21
 */
public class Contains extends BaseFn {
    @Override
    public Object call(Object[] arguments, FelContext context) {
        Object argument = arguments[0];
        String argument1 = String.valueOf(arguments[1]);
        List<Object> objects = JSON.parseArray(argument1).toJavaList(Object.class);
        return objects.contains(argument);
    }

    @Override
    public String getZwmc() {
        return "包含";
    }

    @Override
    public boolean isExport() {
        return true;
    }

    @Override
    public boolean isBuiltIn() {
        return true;
    }

    @Override
    public List<Param> getParams() {
        List<Param> params = new ArrayList<>();
        params.add(new Param("param1"));
        params.add(new Param("arrryStr"));
        return params;
    }

    @Override
    public String getName() {
        return "contains";
    }
}
